package com.sj.boot.modules.sys.web;


import com.sj.boot.modules.sys.model.Activity;
import com.sj.boot.modules.sys.service.ActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("app/activity/")
@Slf4j
public class ActivityController {

    private final ActivityService activityService;

    public ActivityController(ActivityService activityService) {
        this.activityService = activityService;
    }


    @PostMapping("add")
    public Activity addActivity(@RequestBody Activity activity){
        return activityService.SaveOrUpdateActivity(activity);
    }

    @GetMapping(value = "get/{id}")
    public Activity getActivity(@PathVariable("id") Long id){
        log.info("接受Activity获取参数{}",id);
        return activityService.getActivityById(id);
    }

    @GetMapping(value = "getAll")
    public List<Activity> getAll(){
        return activityService.getAll();
    }

}
